<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 	
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
<link rel="stylesheet" href="/css/jquery.tooltip.css" />
<script src="/js/jquery.tooltip.min.js" type="text/javascript"></script>
<h1>商品管理 - 商品规格<br/>
	<div class="f-link">
		<a href="<%=ServerValue.getMidContextPath()%>/product/list.do">回商品列表页</a>
	</div>
</h1>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br/>
<!-- include product step menu -->
<jsp:include page="commonMenu2.jsp"/>
<s:form action="saveSecondSpec.do" method="post" id="specForm">
	<table class="tb-data" width="100%">
		<thead>
		 <tr>
				<th>商品名称<br/>（商品编号）</th>
				<td>${product.productName}(${productId})</td>
		 </tr>
		</thead>
	</table>
	<br/>
	<c-rt:forEach items="${product.specMajors}" var="major" varStatus="rows_index">
	<br/>主規格：${major.mainSpecName}
	<table class="tb-data" width="100%">
		<thead>
	   	<tr>
		   	<th>次规格</th>
		   	<th>规格料号</th>
		   	<th>规格条码</th>
		   	<th>单笔订单<br/>最大可销售数量</th>
		    <th>单笔订单<br/>最小可销售数量</th>
		    <th>安全库存量</th>
		    <th>可售数</th>
				<th>已售数</th>
				<th>取消数</th>
				<th>排序</th>
				<th>启用/停用</th>
				<th>销售库存查询</th>
	   	</tr>
	  </thead>
		<tbody>
			<c-rt:forEach items="${product.specMap[major.mainSpecName]}" var="spec" varStatus="rows_index">
				<tr>
					<td>${spec.secondSpecName}
						<input type="hidden" name="spcId" value="${spec.specificationId}" />
						<!-- <input type="text" name="spcName" id="spcName_${rows_index.count}" size="15" maxlength="25" value="${spec.secondSpecName}" /> -->
					</td>
					<td><input type="text" name="spcCode" id="spcCode" size="10" maxlength="20" value="${spec.specCode}" /></td>
					<td><input type="text" name="spcBarCode" id="spcBarCode" size="10" maxlength="20" value="${spec.barCode}" /></td>
					<td><input type="text" name="spcMaxCountPerOrder" maxlength="8" id="spcMaxCountPerOrder_${rows_index.count}" size="5" value="${spec.maxCountPerOrder}" /></td>
					<td><input type="text" name="spcMinCountPerOrder" maxlength="8" id="spcMinCountPerOrder_${rows_index.count}" size="5" value="${spec.minCountPerOrder}" /></td>
					<td><input type="text" name="spcSafeInventory" maxlength="8" id="spcSafeInventory_${rows_index.count}" size="5" value="${spec.safeInventory}" /></td>
					<td>${(specInvMap[spec.specificationId][0] - specInvMap[spec.specificationId][1] + specInvMap[spec.specificationId][2])<=0?'0':(specInvMap[spec.specificationId][0] - specInvMap[spec.specificationId][1] + specInvMap[spec.specificationId][2])}</td>
					<td>${specInvMap[spec.specificationId][1]}</td>
					<td>${specInvMap[spec.specificationId][2]}</td>
					<td><input type="text" name="showSpecSeq" maxlength="2" id="showSeq_${rows_index.count}" size="2" value="${empty spec.showSeq?'1':spec.showSeq}" /></td>
					<td><input name="spcDelete" type="checkbox" value="${spec.specificationId}" ${spec.isDelete eq "Y" ? "checked='checked'" : "" }/></td>
					<td><a href="<%=ServerValue.getMidContextPath()%>/product/orderNotShipping.do?specificId=${spec.specificationId}&productId=${productId}" target="_blank">查询</a></td>
				</tr>
			</c-rt:forEach>
			<tr class="">
	    	<td>
	      	<input type="hidden" name="spcId" value="" />
					<input type="text" name="spcName" id="spcName" size="8" maxlength="8" value="" />
				</td>
	      <td><input type="text" name="spcCode" id="spcCode" size="10" maxlength="20" value="" /></td>
	      <td><input type="text" name="spcBarCode" id="spcBarCode" size="10" maxlength="20" value="" /></td>
	      <td><input type="text" name="spcMaxCountPerOrder" maxlength="8" id="spcMaxCountPerOrder" size="5" value="" /></td>
	      <td><input type="text" name="spcMinCountPerOrder" maxlength="8" id="spcMinCountPerOrder" size="5" value="" /></td>
	      <td><input type="text" name="spcSafeInventory" maxlength="8" id="spcSafeInventory" size="5" value="" /></td>
	      <td>0</td>
				<td>0</td>
				<td>0</td>
	      <td><input type="text" name="showSpecSeq" maxlength="2" id="showSeq" size="2" value="1" /></td>
	      <td></td>
	    </tr>
	    <tr>
	    	<td colspan="12">
	    		<input type="button" name="add" value="+"/><input type="button" name="del" value="-"/>
	    	</td>
	    </tr>                        			
		</tbody>
	</table>
	</c-rt:forEach>
		<tr class="">
			<td>
				<input type="hidden" id="productId" name="productId" value="${productId}"/>
				<input type="hidden" id="mainSpecId" name="mainSpecId" value="${major.mainSpecId}"/>
				<input type="submit" id="submit_button" value="储存商品规格"/>
			</td>
		</tr>		
	
</s:form>
<div id="secondSpecDialog">
	
</div> 